//session
const express = require('express');
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');
var server = express();

//cookie
server.use(cookieParser('abcdefg'));

//sesseion
server.use(cookieSession({
    name:'test',  // 修改session默认名称
    keys:['aaa','bbb','ccc'],
    maxAge:24*60*1000  // 有效期
}));  //放在cookieparser的后面

server.use('/', function (req, res) {
    if( req.session['count'] == null )
    {
        req.session['count'] = 1;
    }else{
        req.session['count']++;
    }
    console.log(req.session);
    res.send('ok');
});


server.listen(8080);